/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.dh2011.security.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Obama
 */
@Entity
@Table(name = "SECURITY_ACC_ROLE_PERMISSION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SecurityAccRolePermission.findAll", query = "SELECT s FROM SecurityAccRolePermission s"),
    @NamedQuery(name = "SecurityAccRolePermission.findById", query = "SELECT s FROM SecurityAccRolePermission s WHERE s.id = :id")})
public class SecurityAccRolePermission implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "ID")
    private String id;
    @JoinColumn(name = "ROLE_ID", referencedColumnName = "ROLE_ID")
    @ManyToOne
    private SecurityRole roleId;
    @JoinColumn(name = "PERMISSION_ID", referencedColumnName = "PERMISSION_ID")
    @ManyToOne
    private SecurityPermission permissionId;
    @JoinColumn(name = "ACCOUNT_ID", referencedColumnName = "ACCOUNT_ID")
    @ManyToOne
    private SecurityAccount accountId;

    public SecurityAccRolePermission() {
    }

    public SecurityAccRolePermission(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public SecurityRole getRoleId() {
        return roleId;
    }

    public void setRoleId(SecurityRole roleId) {
        this.roleId = roleId;
    }

    public SecurityPermission getPermissionId() {
        return permissionId;
    }

    public void setPermissionId(SecurityPermission permissionId) {
        this.permissionId = permissionId;
    }

    public SecurityAccount getAccountId() {
        return accountId;
    }

    public void setAccountId(SecurityAccount accountId) {
        this.accountId = accountId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SecurityAccRolePermission)) {
            return false;
        }
        SecurityAccRolePermission other = (SecurityAccRolePermission) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.herenit.beijing.dh2011.security.SecurityAccRolePermission[ id=" + id + " ]";
    }
    
}
